﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace GeuzenAdministratie
{
    public partial class MemberProperties : Form
    {
        int member_id;
        string curKNSA;

        public MemberProperties()
        {
            InitializeComponent();
        }
        public MemberProperties(string member_id)
        {
            InitializeComponent();
            this.member_id = Convert.ToInt32(member_id);
            DBConnect db = new DBConnect();
            DataRow row = db.getOneMember(member_id).Rows[0];
            txtInitial.Text = row["initial"].ToString();
            txtTussenvoegsel.Text = row["tussenvoegsel"].ToString();
            txtlastName.Text = row["lastName"].ToString();
            txtKNSA.Text = row["KNSA"].ToString();
            curKNSA = row["KNSA"].ToString();
        }

        private void btnSave_Click(object sender, EventArgs e)
        {
            DBConnect db = new DBConnect();
            //check of user bewerkt wordt of nieuw aan wordt gemaakt
            if (member_id != 0)
            {
                db.Update(txtInitial.Text, txtTussenvoegsel.Text, txtlastName.Text, txtKNSA.Text, member_id, curKNSA);
            }
            else
            {
                db.Insert(txtInitial.Text, txtTussenvoegsel.Text, txtlastName.Text, txtKNSA.Text);
            }
            this.Close();
        }
    }
}
